package com.hntech.web.handler;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @Autho changqi.wu
 * @Date 路在脚下，使劲踩！
 */
@Component
public class RouteHandler {

    public RouteLocator customerRouteLocator(RouteLocatorBuilder builder) {
        return builder.routes()
                //指定路径  --指定路径
                .route("path_route", r -> r.path("/get").uri("http://localhost:9001/"))
                //域名跳转  -- 指定域名
                .route("domain_route", r -> r.host("www.test.com").uri("http://localhost:9001/"))
                //域名跳转  -- 正则
                .route("domain_route", r -> r.host("www.*.com").uri("http://localhost:9001/$1/"))



                .build();
    }

}
